package com.example.composedialogdemo.dialog

import androidx.compose.foundation.Image
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties
import com.example.composedialogdemo.R

/**
 * @author: smile
 * @date:   2025/9/10 1:06
 * @desc:   游玩时长充值弹框
 */
@Composable
fun RechargeTipsDialog(
    onDismiss: () -> Unit,
    onRechargeClick: () -> Unit
) {
    Dialog(
        onDismissRequest = onDismiss,
        properties = DialogProperties(
            dismissOnBackPress = false,
            dismissOnClickOutside = false
        )
    ) {
        // 全屏容器
        Box(
            modifier = Modifier.fillMaxSize(),
            contentAlignment = Alignment.Center
        ) {
            // 背景图片
            Image(
                painter = painterResource(id = R.drawable.ic_time_recharge),
                contentDescription = "充值背景",
                modifier = Modifier.fillMaxSize()
            )

            // 内容 Column
            Column(
                horizontalAlignment = Alignment.CenterHorizontally,
                verticalArrangement = Arrangement.Center,
                modifier = Modifier.fillMaxSize()
            ) {
                // 提示文本
                Text(
                    text = stringResource(id = R.string.your_free_time_has_been_exhausted_please_recharge),
                    color = Color.White,
                    fontSize = 22.sp,
                    textAlign = TextAlign.Center,
                    modifier = Modifier.padding(top = 50.dp)
                )

                // 充值按钮区域
                Box(
                    modifier = Modifier.padding(top = 10.dp, bottom = 6.dp)
                ) {
                    // 充值按钮图片
                    Image(
                        painter = painterResource(id = R.mipmap.ic_recharge),
                        contentDescription = "去充值",
                        modifier = Modifier
                            .size(width = 261.dp, height = 110.dp)
                            .clickable { onDismiss() }
                    )
                    // 确认文本
                    Text(
                        text = stringResource(id = R.string.sure),
                        color = Color.White,
                        fontSize = 18.sp,
                        textAlign = TextAlign.Center,
                        modifier = Modifier
                            .align(Alignment.Center)
                            .padding(bottom = 6.dp)
                    )
                }
            }
        }
    }
}